namespace Digitalmes.Domain.Sys;

/// <summary>
/// 资源菜单表
/// </summary>
[SugarTable("sys_menu", "资源菜单表")]
public class SysMenu : EntityTenantBase
{
    /// <summary>
    /// 菜单名称
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "菜单名称", Length = 32)]
    public string? Name { get; set; }

    /// <summary>
    /// 父节点
    /// </summary>
    [SugarColumn(ColumnDescription = "父节点")]
    public long ParentId { get; set; }

    /// <summary>
    /// 父节点集合组
    /// </summary>
    [SugarColumn(ColumnDescription = "父节点集合组", IsJson = true, Length = 256)]
    public List<long> ParentIdList { get; set; } = new();

    /// <summary>
    /// 权限标识
    /// </summary>
    [SugarColumn(ColumnDescription = "权限标识", Length = 32)]
    public string? Code { get; set; }

    /// <summary>
    /// 菜单层级
    /// </summary>
    [SugarColumn(ColumnDescription = "菜单层级")]
    public int Layer { get; set; } = 1;

    /// <summary>
    /// 路由地址
    /// </summary>
    [SugarColumn(ColumnDescription = "路由地址", Length = 128)]
    public string? Urls { get; set; }

    /// <summary>
    /// 重定向
    /// </summary>
    [SugarColumn(ColumnDescription = "重定向", Length = 128)]
    public string? Redirect { get; set; }

    /// <summary>
    /// Vue文件路径
    /// </summary>
    [SugarColumn(ColumnDescription = "Vue文件路径", Length = 128)]
    public string? VuePath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    [SugarColumn(ColumnDescription = "菜单图标", Length = 64)]
    public string? Icon { get; set; }

    /// <summary>
    /// 高亮
    /// </summary>
    [SugarColumn(ColumnDescription = "高亮", Length = 64)]
    public string? Active { get; set; }

    /// <summary>
    /// 颜色
    /// </summary>
    [SugarColumn(ColumnDescription = "颜色", Length = 32)]
    public string? Color { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [SugarColumn(ColumnDescription = "排序")]
    public int Sort { get; set; } = 1;

    /// <summary>
    /// 是否全屏
    /// </summary>
    [SugarColumn(ColumnDescription = "是否全屏")]
    public bool FullPage { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [SugarColumn(ColumnDescription = "状态")]
    public bool Status { get; set; } = true;

    /// <summary>
    /// 是否删除
    /// </summary>
    [SugarColumn(ColumnDescription = "是否删除")]
    public bool IsDel { get; set; }

    /// <summary>
    /// 菜单类型
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "菜单类型", Length = 20)]
    public string? Types { get; set; }

    /// <summary>
    /// 接口权限集合
    /// </summary>
    [SugarColumn(ColumnDescription = "菜单类型", IsJson = true, Length = 2048)]
    public List<SysMenuApiUrl> Api { get; set; } = new();
}

/// <summary>
/// 接口权限
/// </summary>
public sealed class SysMenuApiUrl
{
    /// <summary>
    /// 权限名称
    /// </summary>
    public string? name { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string? code { get; set; }

    /// <summary>
    /// 方法
    /// </summary>
    public string? method { get; set; }

    /// <summary>
    /// Api url
    /// </summary>
    public string? url { get; set; }
}
